import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from "unplugin-vue-components/vite"
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers:[ElementPlusResolver()]
    })
  ],
  resolve:{
    alias:{
      "@":"/src",
      "components":"/src/components",
      "assets":"/src/assets"
    }
  },
  server: {
    open: true, //默认启动程序就打开浏览器
    host: "127.0.0.1",
    port: 80,
    proxy:{
      '/api':{
        target:"http://localhost:5068/api/",//转发地址
        changeOrigin:true,//启用跨域访问
        rewrite: path => path.replace(/^\/api/, '') //修改请求路径
        // rewrite(path) {
        //   return path.replace(/^\/api/, '')
        // },
      }
    }
  }
})
